<?php
`git config --global user.name 练习生两年半`;
`git config --global user.email 2900068913@qq.com`;
$state=`sc query mysql`;
if(strpos($state, 'STOPPED')>0){
    `net start mysql`;
}

$db=new PDO("mysql:host=localhost", "root", "12qwas");
$db->exec("create database if not exists db2;");
$db->exec("use db2");
$db->exec("create table if not exists users (name varchar(50) primary key, age int)");

$count=$db->exec("delete from users where age>=20");
echo "成功删除了 $count 条记录~\n";
$db->exec('truncate table users');//删除表中的所有数据
$count=$db->exec("insert into users (name, age) values ('张三', 20),('李四',18),('王五',21)");
echo "成功插入了 $count 条记录~\n";
$count=$db->exec("update users set name='张三丰' where name='张三'");
echo "成功修改了 $count 条记录~\n";
$ps=$db->query("select * from users");
foreach($ps as $row){
    //print_r($row);
    echo "$row[name]   $row[age]\n";
}